Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addinstance function #138

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Addinstance function #138

wants to merge 17 commits into from

Conversation

francescalb
Copy link
Contributor

Description:

Added function for creating instance

Type of change:

  • Bug fix.
  • New feature.
  • Documentation update.

Checklist for the reviewer:

This checklist should be used as a help for the reviewer.

  • Is the change limited to one issue?
  • Does this PR close the issue?
  • Is the code easy to read and understand, including clearly named variables?
  • Do all new feature have an accompanying new test?
  • Has the documentation been updated as necessary?

@codecov-commenter
Copy link

codecov-commenter commented May 22, 2023

Codecov Report

Patch coverage: 91.17% and project coverage change: +10.90 🎉

Comparison is base (127ca43) 67.32% compared to head (ccffaff) 78.23%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #138       +/-   ##
===========================================
+ Coverage   67.32%   78.23%   +10.90%     
===========================================
  Files          14       15        +1     
  Lines         352      386       +34     
===========================================
+ Hits          237      302       +65     
+ Misses        115       84       -31     
Flag Coverage Δ
linux 78.23% <91.17%> (+10.90%) ⬆️
windows 78.06% <91.17%> (+11.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
oteapi_dlite/strategies/function.py 77.27% <ø> (+77.27%) ⬆️
oteapi_dlite/strategies/add_instance.py 91.17% <91.17%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@francescalb francescalb requested a review from jesper-friis May 22, 2023 06:33

function_config: DLiteAddInstanceConfig

def initialize(
Copy link
Contributor

@jesper-friis jesper-friis Jun 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be even more useful to add the instance during the initialise phase?
Probably not... when thinking more about it.

"""Configuration for adding an instance to the collection."""

datamodel: str = Field(
description="ID (URI or UUID) of the datamodel.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be mentioned that the data model must be available in dlite.storage_path.

Comment on lines +1 to +13
{
"7bad2efc-cb40-420b-aef9-2f909d038b46": {
"meta": "http://onto-ns.com/meta/0.1/Result",
"dimensions": {
"natoms": 2,
"ncoords": 3
},
"properties": {
"potential_energy": 0,
"forces": [[0, 0, 0], [0, 0, 0]]
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no point in committing a file that is generated.

But more worrying is that the properties are uninitialised. We should test that they are correctly assigned.

)

pipeline = add_instance >> generate
pipeline.get()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[After running the pipeline, we should test that the file is created and has the expected content. For example

import numpy as np

inst = dlite.Instance.from_location("json", f"{outdir}/test_add_instance.json", options="mode=r")
assert np.allclose(inst.potential_energy, 3.2e-19)
assert np.allclose(inst.forses, [[1.2, 2.3, 3.4], [0.2, 3.4, 4.5]])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants